package top.zuli.package01.class13;

public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread1();
        Thread t2 = new Thread2();
        t1.start();
        t2.start();
    }
}
//1.打印偶数线程
class Thread1 extends  Thread{
    @Override
    public void run() {
        for (int i = 0; i <=100; i++) {
            if(i%2==0){
                try {
                    sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName()+":"+i);
            }
        }
    }
}
//2.打印奇数线程
class Thread2 extends  Thread{
    @Override
    public void run() {
        for (int i = 0; i <=100; i++) {
            if(i%2!=0){
                try {
                    sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName()+":"+i);
            }
        }
    }
}